<template>
    <view class="gjl-view">
        <view class="main">
            <view class="title">{{title}}</view>
            <jParse :html="content"></jParse>
        </view>
    </view>
</template>

<script>
    import service from "@/service";
    import jParse from '@/components/jyf-parser/jyf-parser.vue'
    export default {
        components:{
            jParse
        },
        data(){
            return {
                pos: {},
                content: '',
                title: ''
            }
        },
        onLoad(res) {
            this.pos = res
            this.setTitle(res.type,res.index)
            this.getData(res.type,res.index)
        },
        methods:{
            // 获取数据
            getData(type,index){
                if(type == 2){
                    service.mineService.plan({
                        data: {
                            planId: this.pos.id
                        },
                        success: res => {
                            this.content = res.result.planDetails
                            this.title = res.result.planTitle
                        },
                        fail: ()=>{
                            
                        },
                        complete: () => {
                            uni.hideLoading();
                        },
                    });
                }
                service.mineService.Texts({
                    data: {
                        textType: index
                    },
                    success: res => {
                        this.content = res.result.textContent
                    },
                    fail: ()=>{
                        
                    },
                    complete: () => {
                        uni.hideLoading();
                    },
                });
            },
            // 设置导航
            setTitle(type,index){
                if(type == 2){
                    uni.setNavigationBarTitle({
                        title: '合伙人计划详情'
                    });
                    return 
                }
                if(type == 1){
                    if(index == 1){
                        uni.setNavigationBarTitle({
                            title: '合伙人规则'
                        });
                    }else if(index == 2){
                        uni.setNavigationBarTitle({
                            title: '结算规则'
                        });
                    }else if(index == 3){
                        uni.setNavigationBarTitle({
                            title: '推广指导群'
                        });
                    }else if(index == 4){
                        uni.setNavigationBarTitle({
                            title: '如何推广'
                        });
                    }else if(index == 5){
                        uni.setNavigationBarTitle({
                            title: '注意事项'
                        });
                    }
                }
            }
        }
    }
</script>

<style scoped lang="scss">
    .gjl-view{
        .title{
            margin-top: 30rpx;
        }
        .main{
            margin: 30rpx;
        }
    }
</style>